import 'package:flutter/material.dart';
import '../../l10n/app_localizations.dart';

class RegisInputView extends StatefulWidget {
  final void Function(int type) clickType;
  const RegisInputView({super.key, required this.clickType});

  @override
  State<RegisInputView> createState() => _RegisInputViewState();
}

class _RegisInputViewState extends State<RegisInputView> {
  int type = 0;

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Color(0xFFF5F5F5),
      child: Column(
        children: [
        Row(
          children: [
            Flexible(
              flex: type == 0 ? 12 : 10,
              child: GestureDetector(
                onTap: () {
                  setState(() {
                    type = 0;
                    widget.clickType(type);
                  });
                },
                child: Container(
                  height: 60,
                  decoration: type == 0
                      ? BoxDecoration(
                          image: DecorationImage(
                            image: AssetImage('assets/images/login_left.png'),
                            fit: BoxFit.cover,
                          ),
                        )
                      : BoxDecoration( // 👈 加上这一段
                        color: Colors.transparent,
                      ),
                  child: Center(
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        Image.asset(
                          type == 0 ? 'assets/images/login_mail_select.png' : 'assets/images/login_mail_normal.png',
                          width: 18,
                          height: 18,
                        ),
                        SizedBox(width: 8),
                        Text(
                          AppLocalizations.of(context)!.mailbox,
                          style: TextStyle(
                            color: type == 0 ? Color(0xFF5D5FEE) : Color(0xFF505050),
                            fontSize: type == 0 ? 15 : 14,
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
              ),
            ),
            Flexible(
              flex: type == 1 ? 12 : 10,
              child: GestureDetector(
                onTap: () {
                  setState(() {
                    type = 1;
                    widget.clickType(type);
                  });
                },
                child: Container(
                  height: 60,
                  decoration: type == 1
                      ? BoxDecoration(
                          image: DecorationImage(
                            image: AssetImage('assets/images/login_right.png'),
                            fit: BoxFit.cover,
                          ),
                        )
                      : BoxDecoration( // 👈 加上这一段
                        color: Colors.transparent,
                      ),
                  child: Center(
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        Image.asset(
                          type == 1 ? 'assets/images/login_phone_select.png' : 'assets/images/login_phone_normal.png',
                          width: 18,
                          height: 18,
                        ),
                        SizedBox(width: 8),
                        Text(
                          AppLocalizations.of(context)!.phoneNumber,
                          style: TextStyle(
                            color: type == 1 ? Color(0xFF5D5FEE) : Color(0xFF505050),
                            fontSize: type == 1 ? 15 : 14,
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
              ),
            ),
          ],
        ),
      ],
      ),
    );
  }
}